package com.nioserver.io;

import com.nioserver.linklayer.Socket;

import java.io.IOException;
import java.util.Queue;
import java.util.concurrent.*;

public class WorkPool implements Runnable {


    int maxThread;
    private static WorkPool Instance;

    public static WorkPool getInstance(){
        if(Instance == null){
            synchronized (WorkPool.class){
                // 第二次检查
                if(Instance==null){
                    // 问题出在此处
                    Instance = new WorkPool();
                }
            }
        }
        return Instance;
    }
    Queue<Socket> channels;
    ExecutorService pool;
    @Override
    public void run() {
        while (true){


        }
    }

    public WorkPool(){
        channels = new ConcurrentLinkedQueue<>();
        //创建使用固定线程数的线程池
        pool =Executors.newFixedThreadPool(16);
    }
    public void submitTask(Runnable task){
        pool.execute(task);
    }
}
